package com.musemun.controller;

import com.musemun.common.CommonResult;
import com.musemun.common.ResultUtil;
import com.musemun.service.function.CulturalRelicsNumber;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 文物清点模块
 * </p>
 *
 * @author ZWYZY
 * @since 2020/4/27
 */
@RestController
@RequestMapping("/crms/crmsCheck")
@Api(tags = "文物清点", description = "文物清点模块")
@Validated
public class CulturalRelicsNumberController {
    @Resource
    private CulturalRelicsNumber culturalRelicsNumber;

    @ApiOperation("查询未清点的文物信息（小）")
    @GetMapping("/getUnCheck")
    public CommonResult getUncheck() {
        return ResultUtil.success(culturalRelicsNumber.getUnCheck());
    }

    @ApiOperation(value = "获取货架位置信息(小)", httpMethod = "GET")
    @ApiImplicitParam(name = "crNo", value = "文物编号", required = true)
    @GetMapping("/getPosition/{crNo}")
    public CommonResult getPosition(@PathVariable Long crNo) {
        return ResultUtil.success(culturalRelicsNumber.getPosition(crNo));
    }

    @ApiOperation(value = "输入收储地点判断文物货架信息（小）", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "crAddr", value = "文物位置", required = true), @ApiImplicitParam(name = "crNo", value = "文物编号", required = true)
    })
    @GetMapping("/isUpdateCheck")
    public CommonResult isUpdateCheck(@RequestParam String crAddr, @RequestParam Long crNo) {
        return ResultUtil.success(culturalRelicsNumber.check(crAddr, crNo));
    }

    @GetMapping("/getHouse")
    @ApiOperation(value = "获取收储仓库数组（小）", httpMethod = "GET")
    public CommonResult getHouse() {
        return ResultUtil.success(culturalRelicsNumber.getHouse());
    }

    @GetMapping("/listByUnScan")
    @ApiImplicitParam(name = "crNoList", value = "文物编号数组", required = true)
    @ApiOperation(value = "扫码后的异常文物id数组查询文物（小）", httpMethod = "GET")
    public CommonResult listByUnScan(@RequestParam Long[] crNoList) {
        return ResultUtil.success(culturalRelicsNumber.listByUnScan(crNoList));
    }

    @GetMapping("/listByScan")
    @ApiImplicitParam(name = "crNoList", value = "文物编号数组", required = true)
    @ApiOperation(value = "扫码后的文物id数组查询文物（小）", httpMethod = "GET")
    public CommonResult listByScan(@RequestParam Long[] crNoList) {
        return ResultUtil.success(culturalRelicsNumber.listByScan(crNoList));
    }

    @PostMapping("/record")
    @ApiImplicitParam(name = "crNoList", value = "文物编号数组", required = true)
    @ApiOperation(value = "将异常的文物记录到异常表里面(小)", httpMethod = "POST")
    public CommonResult record(@RequestParam Long[] crNoList) {
        return ResultUtil.success(culturalRelicsNumber.record(crNoList));
    }

    @ApiOperation(value = "修改文物收储位置信息（小）", httpMethod = "PUT")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "crAddr", value = "文物位置", required = true), @ApiImplicitParam(name = "crNo", value = "文物编号", required = true)
    })
    @PutMapping("/update")
    public CommonResult update(@RequestParam String crAddr, @RequestParam Long crNo) {
        return ResultUtil.success(culturalRelicsNumber.update(crAddr, crNo));
    }
    @GetMapping("/selectAbnormal")
    @ApiOperation(value = "异常表查询（小）", httpMethod = "GET")
    public CommonResult selectAbnormal()
    {
        return ResultUtil.success(culturalRelicsNumber.selectAbnormal());
    }
}
